package cwnu.sapphire.com.controller;

import cwnu.sapphire.com.entity.Admin;
import cwnu.sapphire.com.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/admins")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @GetMapping
    public List<Admin> list() {
        return adminService.list();
    }

    @GetMapping("/{id}")
    public Admin getById(@PathVariable Integer id) {
        return adminService.getById(id);
    }

    @PostMapping
    public boolean add(@RequestBody Admin admin) {
        return adminService.save(admin);
    }

    @PutMapping
    public boolean update(@RequestBody Admin admin) {
        return adminService.updateById(admin);
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id) {
        return adminService.removeById(id);
    }
} 